package com.xuecheng.content.listener;

import com.xuecheng.content.service.CoursePubService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created on 2021/04/11/11:49 周日
 *
 * @author Lantin
 */

@Component
@RocketMQMessageListener(topic = "${rocketmq.massage.topic}", consumerGroup = "consumer-group-course-pub-main")
@Slf4j
public class CoursePublishListener implements RocketMQListener<Long> {

    @Autowired
    private CoursePubService coursePubService;

    @Override
    public void onMessage(Long message) {
        //消费者收到消息就执行本地方法
        log.info("消费方收到消息，开始消费，课程id：{}", message);
        coursePubService.publishPage(message);
    }
}
